﻿#include "Readline.h"

std::string READ(const std::string &input);
std::string EVAL(const std::string &input);
std::string PRINT(const std::string &input);
std::string Rep(const std::string &input);

static Lisp::Readline s_readline;

int main()
{
  std::string prompt = "user> ";
  std::string input;
  while (s_readline.Get(prompt, input))
  {
    if (input.empty())
      continue;

    try {
      std::cout << Rep(input) << std::endl;
    } catch (const std::exception &e) {
      std::cout << "Err: " << e.what() << std::endl;
    }
  }
  return 0;
}

std::string READ(const std::string &input)
{
  return input;
}

std::string EVAL(const std::string &input)
{
  return input;
}

std::string PRINT(const std::string &input)
{
  return input;
}

std::string Rep(const std::string &input)
{
  return PRINT(EVAL(READ(input)));
}